package com.tangyh.lamp.common.enums;

import com.tangyh.basic.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 企业用户
 * </p>
 *
 * @author system
 * @date 2021-08-17
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "UserType", description = "用户类型-枚举")
public enum UserType implements BaseEnum {

    /**
     * PARK="园区"
     */
    PARK("园区"),
    /**
     * MERCHANT="商户"
     */
    MERCHANT("商户"),
    /**
     * MERCHANT_SUB_ACCOUNT="商户子账号"
     */
    MERCHANT_SUB_ACCOUNT("商户子账号"),
    /**
     * CHANNEL="渠道"
     */
    CHANNEL("渠道"),

    TENANT("租户"),
    /**
     * PERSONAL="个人"
     */
    PERSONAL("个人"),
    /**
     * PERSONAL="管理员"
     */
    PT_ADMIN("管理员"),//实际没有，后期删掉
    /**
     * SUPERVISION="监管"
     */
    SUPERVISION("监管"),//实际没有，后期删掉

    /**
     * FREELANCER="自由职业"
     */
    FREELANCER("自由职业"),

    GROUP("集团账号"),

    OPERRATOR("运营账户"),

    MANAGER_caiwu("财务"),
    MANAGER_shyy("上海运营"),
    MANAGER_OPT_ADMIN("运营管理员"),
    MERCHANT_JING_BAN("经办"),
    MERCHANT_SALESMAN("业务员")
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static UserType match(String val, UserType def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static UserType get(String val) {
        return match(val, null);
    }

    public boolean eq(UserType val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "PARK,MERCHANT,PERSONAL", example = "PARK")
    public String getCode() {
        return this.name();
    }

}
